/*select code blocks of bbcode*/
function selectCode(a){
    // Get ID of code block
    var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];

    // Not IE
    if (window.getSelection){
        var s = window.getSelection();
        // Safari
        if(s.setBaseAndExtent){
            s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
        }else{// Firefox and Opera
            if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>'){
                e.innerHTML = e.innerHTML + '&nbsp;';
            }

            var r = document.createRange();
            r.selectNodeContents(e);
            s.removeAllRanges();
            s.addRange(r);
        }
    }else if (document.getSelection){// Some older browsers
        var s = document.getSelection();
        var r = document.createRange();
        r.selectNodeContents(e);
        s.removeAllRanges();
        s.addRange(r);
    }
    // IE
    else if (document.selection){
        var r = document.body.createTextRange();
        r.moveToElementText(e);
        r.select();
    }
}

/*click to check all and uncheck all*/
function marklist(id, name, state){
	var parent = document.getElementById(id);
	if (!parent){
		eval('parent = document.' + id);
	}

	if (!parent){
		return;
	}

	var rb = parent.getElementsByTagName('input');

	for (var r = 0; r < rb.length; r++){
		if (rb[r].name.substr(0, name.length) == name){
			rb[r].checked = state;
		}
	}
}

/*drop down list*/
function rolloverMenu(showHide, menu, navi_button)
{
    var linkObj = document.getElementById(navi_button);
    var menuObj = document.getElementById(menu);
    if (showHide == 0)
    {
        menuObj.style.display = 'none';
        linkObj.setAttribute('class', 'quick-nav-button');
        linkObj.setAttribute('className', 'quick-nav-button');
    }
    else
    {
        menuObj.style.display = 'block';
        linkObj.setAttribute('class', 'selectedRollover');
        linkObj.setAttribute('className', 'selectedRollover');
    }
}